package javase.javase02.thread;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author: Gan
 * @date 2021/4/21 0021 14:33
 * @description:
 **/
public class DemoNet {
    public static void main(String[] args) throws UnknownHostException {
        // InetAddress ip = new InetAddress();
        InetAddress myAddr = InetAddress.getLocalHost();
        System.out.println("本地主机ip："+myAddr.getHostAddress());
        System.out.println("本地计算机名称："+myAddr.getHostName());
        InetAddress addr = InetAddress.getByName("baidu.com");
        System.out.println("百度服务器的IP："+addr.getHostAddress());
        System.out.println("百度服务器的名称："+addr.getHostName());

    }
}
